feat: add stable agent error contract - #32
Conversation
|
Re-reviewed at The human-mode blast radius is fixed. The envelope and the code table match issue #12 faithfully. Two things still open. 1. The docs say "explicit" but the gate is
|
|
Re-reviewed at The human-mode blast radius is fixed. The envelope and the code table match issue #12 faithfully. Two things still open. 1. The docs say "explicit" but the gate is
|
Summary
Part of #12. API idempotency keys remain a server-side follow-up.
Test methods
Automated validation run on this branch:
go test ./... go vet ./...Manual validation:
The explicit agent command should produce one JSON error on stderr and a specific non-zero exit code. The redirected non-agent command should retain the API response body in the output file and keep the pre-existing CLI exit behavior.
Could this break things?
Risk: medium, limited to explicit agent mode. Scripts using
--agent,DCI_AGENT_MODE=1, or a detected agent environment may now receive specific failure exit codes instead of1and a JSON error envelope instead of duplicate human-readable stderr. Ordinary redirection, pipes, CI use, API requests, and successful output retain their previous behavior.Example contract:
{"error":{"code":"AUTHENTICATION_FAILED","message":"...","hint":"Run: dci login","retryable":false,"http_status":401}}